package com.qf.controller;

import com.qf.dao.TakeOutStoreInfoMapper;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName TakeOutController
 * @Description TODO
 * @Author 16222
 * @Date 2022/9/28 19:26
 * @Version 1.0
 **/
@RestController
@RequestMapping("takeout")
@Api(tags = "外卖模块接口，其他的接口相同也可以用 ")
public class TakeOutController {
    @Autowired
    TakeOutClassifyService takeOutClassifyService;
    @Autowired
    TakeOutStoreInfoService takeOutStoreInfoService;

    @Autowired
    TakeOutGoodsClassifyService takeOutGoodsClassifyService;
    @Autowired
    TakeOutGoodsService takeOutGoodsService;
    @Autowired
    TakeOutLastService takeOutLastService;
    @GetMapping("findAllClassifyBylistId")
    @ApiOperation(value = "按一级列表（外卖）查询所有的二级分类（汉堡披萨）")
    public BaseResp findAllClassifyBylistId(int id) {
//        int id = (int)map.get("id");
        BaseResp allByListId = takeOutClassifyService.findAllByListId(id);
        return allByListId;
    }

    @GetMapping("findAllByClassifyId")
    @ApiOperation(value = "通过二级分类找店铺")
    public BaseResp findAllByClassifyId(int id) {
//        int id = (int)map.get("id");
        BaseResp allByClassifyId = takeOutStoreInfoService.findAllByClassifyId(id);
        return allByClassifyId;
    }

    @GetMapping("findAllByListId")
    @ApiOperation(value = "通过一级找全部店铺,传入一级分类的id")
    public BaseResp findAllByListId(int id) {
//        int id = (int)map.get("id");
        BaseResp all = takeOutStoreInfoService.findAllByListId(id);
        return all;
    }

    @GetMapping("findAllGoodsClassifyByStoreId")
    @ApiOperation(value = "通过店铺id找食物分类,传入店铺的id")
    public BaseResp findAllGoodsClassifyByStoreId(int id) {
        BaseResp allGoodsClassifyByStoreId = takeOutGoodsClassifyService.findAllGoodsClassifyByStoreId(id);
        return allGoodsClassifyByStoreId;
    }

    @GetMapping("findAllGoodsByGoodsClassify")
    @ApiOperation(value = "通过食物类型找食物,传入食物类型的id")
    public BaseResp findAllGoodsByGoodsClassify(int id) {
        BaseResp allGoodsByGoodsClassify = takeOutGoodsService.findAllGoodsByGoodsClassify(id);
        return allGoodsByGoodsClassify;
    }

    @GetMapping("findAllLastByClassify")
    @ApiOperation(value = "通过二级分类找三级分类,传入二级分类的id")
    public BaseResp findAllLastByClassify(int id) {
        BaseResp allLastByClassify = takeOutLastService.findAllLastByClassify(id);
        return allLastByClassify;
    }
    @GetMapping("findAllStoreByClassifyAndStoreDiscount")
    @ApiOperation(value = "通过二级分类和优惠政策找三级分类,传入二级分类的id和优惠的活动名称")
    public BaseResp findAllStoreByClassifyAndStoreDiscount(int id,String storeDiscount) {
        BaseResp allStoreByClassifyAndStoreDiscount = takeOutStoreInfoService.findAllStoreByClassifyAndStoreDiscount(id, storeDiscount);
        return allStoreByClassifyAndStoreDiscount;
    }
}
